package com.sinai.mshab.client.user;

import com.google.gwt.user.client.Cookies;
import com.sinai.mshab.client.ui.aggregate.FormData;

public class UserFactory {
	
	private static User user;
	
	// keep it a factory
	private UserFactory() {
		
	}
	
	public static User getInstance() {
		if (user == null) {
			user = new LDAPUser();
		}
		return user;
	}

	/**
	 * Check if user can login via cookie and avoid login screen
	 * 
	 * @return true if user has a valid cookie
	 */
	public static boolean loggedIn() {
		String cookie = Cookies.getCookie(FormData.getServletUrl() + " cookie");
		if (cookie == null) {
			return false;
		}
		return true;
	}
}
